Ext.define("PCD.controller.LoginController",{
	extend: "Ext.app.Controller",

	views:[
		"LoginWindow"
	],

	models:[
		"YhModel"
	],

	/*stores:[
		"YhStore"
	],*/

	init:function(){
		console.log("LoginController init");
		this.control({
			"loginwindow button[action=login]":{
				click:this.login
			},"loginwindow button[action=reset]":{
				click:this.reset
			}
		});
	},

	login:function(button){
		var win = button.up('window'),
			form = win.down("form"),
			values = form.getValues();
	
			var params = {
				username:values.xm,
				password:values.password
			};

			$.getJSON("../ajax/login/",params,function(data){
				if(data.success === true){
					win.close();
					loginBack();
				}else{
					alert("登录失败!");
				}
			});
	},

	reset:function(button){
		var win = button.up('window'),
			form = win.down("form");
		form.getForm().reset();
	}
});